#include <REGX52.H>
#include "oled.h"
#include "Delay.h"
#include "picture.h"
#include "DS1302.h"
#include "TimeShow.h"
#include "DS18B20.h"
//#include "LCD1602.h"
#include "Timer1.h"
#include "IR.h"
#include "Key.h"
#include "Nixie.h"

unsigned char KeyNum,Command,Speed,IR_keyNumber=0;
unsigned char MODE = 0;




void main()
{
	IR_Init();
//	Timer1_Init();
//	oled_init();
//	oled_clear();
//	DS1302_Init();
	
//	DS1302_SetTime();
	while(1)
	{
		if(IR_GetDataFlag())
			{
				Command=IR_GetCommand();
				if(Command==IR_0){Speed=0;}
				if(Command==IR_1){Speed=1;}
				if(Command==IR_2){Speed=2;}
				if(Command==IR_3){Speed=3;}
			}	
//			OLED_ShowNum(0,0,Speed,1,8);
			Nixie(1,Speed);
		
//			KeyNum = Key();
//			OLED_ShowNum(96,5,KeyNum,1,8);
//		//按键1进行模式选择,以及模式功能
//			if(KeyNum==1)
//			{
//				if(MODE==0){MODE=1;}
//				else if(MODE==1){MODE=2;oled_clear();}
//				else if(MODE==2){MODE=3;}
//				else if(MODE==3){MODE=0;oled_clear();}
//			}
//			OLED_ShowNum(104,5,MODE,1,8);
//			switch(MODE)
//			{
//				case 0: DS1302_ReadTime();TimeShow();break;
//				case 1: TimeSet(KeyNum);break;
//				case 2: Clock_Show();break;
//				case 3: Clock_Set(KeyNum);break;
//			}
	}
}









//定时器
void Timer1_Routine() interrupt 3
{		
		static unsigned int T1Count1,T1Count2;
		TL1 = 0x9C;		//设置定时初始值
		TH1 = 0xFF;		//设置定时初始值
		T1Count1++;
		if(T1Count1 >= 5000){
				T1Count1=0;
				TimeSetFlash();
		}
		T1Count2++;
		if(T1Count2 >= 200){
				T1Count2=0;
				Key_Loop();
		}
		
}